Skip to content

fix(control-plane): enforce source-session denial in cold snapshot and align consumer adoption test - #8898

Merged
loopx-agent merged 2 commits into
mainfrom
codex/fix-cold-snapshot-source-denial-and-turn-adoption-20261117
Nov 21, 2026
Merged

loopx-agent merged 2 commits into
mainfrom
codex/fix-cold-snapshot-source-denial-and-turn-adoption-20261117

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

Delivery Brief

  • Goal / Source: Restore two failing architecture & control-plane test gates observed on main (a92b123749).
  • Current Gap:
    1. GoalStorageRequestMixin._storage_cold_snapshot in loopx/presentation/goal_storage_api.py loaded routed external registries via load_project_registry instead of load_registry, bypassing source_session_v1 denial (require_runtime_compatible_project_registry) and failing tests/architecture/test_source_session_registry_denial.py::test_direct_project_registry_loaders_have_source_session_denial.
    2. tests/control_plane/test_pr_wait_consumer_adoption.py still monkeypatched removed turn.build_turn_envelope and parsed legacy request["work_contract"] from the DSH host prompt after 8bcef37666 moved Turn preparation to compose_turn_decision and render_prompt switched to loopx_turn_model_context_v0 (task_context via projected_host_model_input).
  • Observable Result:
    1. _storage_cold_snapshot now imports load_registry from loopx.control_plane.projects.registry_codec, enforcing source_session_v1 denial on external routed snapshots while matching sibling _storage_import behavior. Added regression test test_cold_snapshot_rejects_routed_source_session_registry.
    2. test_selected_merge_proof_survives_capture_and_actual_host_adoption now wraps turn.compose_turn_decision, validates the rendered loopx_turn_model_context_v0 prompt payload inside consumer.py and in the post-run check via assert_host_task_context(model_input, full), while retaining build_turn_envelope(full) action_signature tamper coverage.
  • Owning Boundary:
    • Presentation storage API: loopx/presentation/goal_storage_api.py
    • Architecture & control-plane regression tests: tests/architecture/test_source_session_registry_denial.py, tests/control_plane/test_pr_wait_consumer_adoption.py

Verification

Executed from a clean branch worktree after the final edit:

  • uv run --extra test ruff check loopx/presentation/goal_storage_api.py tests/architecture/test_source_session_registry_denial.py tests/control_plane/test_pr_wait_consumer_adoption.py -> All checks passed!
  • uv run --extra test mypy --follow-imports=silent loopx/presentation/goal_storage_api.py -> 0 errors in modified _storage_cold_snapshot (4 pre-existing errors in untouched _storage_import unchanged)
  • uv run --extra test python -m pytest tests/architecture/test_source_session_registry_denial.py tests/control_plane/test_pr_wait_consumer_adoption.py -q -> 16 passed in 13.33s
  • uv run --extra test python -m pytest tests/control_plane/test_chat_cold_source_import.py -k "global-source and not race" -q -> 2 passed, 48 deselected in 6.62s
  • uv run --extra test python examples/control_plane/control-plane-maintainability-ratchet-smoke.py -> control-plane-maintainability-ratchet: ok (unreviewed: 0, stale_exceptions: 0, magnitude_regressions: 0)
  • uv run --extra test python examples/semantic-vocabulary-drift-smoke.py -> semantic-vocabulary-drift-smoke: ok
  • uv run --extra test loopx check --scan-path ... -> public_boundary_scan.ok=true (scanned_files: 3)
  • PR_BASE_REF=origin/main uv run --extra test python scripts/check_rfc_bilingual.py --base "$PR_BASE_REF" --staged -> RFC bilingual diff check passed.

…d align consumer adoption test

Signed-off-by: LoopX Agent <[email protected]>
@loopx-agent
loopx-agent force-pushed the codex/fix-cold-snapshot-source-denial-and-turn-adoption-20261117 branch from 6a91049 to 64f6db6 Compare November 17, 2026 19:32

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent | self_reported | Gemini | Google DeepMind

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

动机 / Motivation

使用 Goal Storage API 冷快照跨注册表路由及 PR wait 消费侧契约测试的开发者与架构守卫。
此前 origin/main 上 goal_storage_api.py:_storage_cold_snapshot 直接调用 load_project_registry(source_registry) 且未在允许名单登记,导致架构测试 test_direct_project_registry_loaders_have_source_session_denial 在全仓持续失败;同时 test_pr_wait_consumer_adoption.py 仍断言已被替换的 build_turn_envelope/work_contract 结构。切换为 load_registry 走统一拒绝策略后,冷快照遇到 source-session 注册表即触发拒绝,两个测试全部恢复通过。
将 goal_storage_api.py:150-154 由 load_project_registry 改为 load_registry,新增 test_cold_snapshot_rejects_routed_source_session_registry 验证拒绝边界,并将 test_pr_wait_consumer_adoption 对齐 compose_turn_decision / task_context。
非目标边界:本 PR 不调整 DIRECT_LOADER_ALLOWLIST 其他已有特例模块,不改写冷快照存储布局。

该修复既消除了 origin/main 上 test_source_session_registry_denial 的持续阻塞红线,也确保冷快照在切到外部 source registry 时严格受 source-session 策略保护。

改动思路 / Approach

直接复用 registry_codec.load_registry 既有安全边界代替绕过式 load_project_registry 直接调用,消除特例豁免,同时顺带修正遗留单测对已退休 work_contract 字段的断言。
当前 PR 边界:仅涵盖 goal_storage_api.py (4 行调整) 与两项测试修正(3 files, +57/-8),rebase 至最新 origin/main。

  • 默认拒绝不变量(_storage_cold_snapshot):路由至外部 source_registry 时统一走 load_registry(source_registry)(内部执行 require_runtime_compatible_project_registry),不再通过未登记的 load_project_registry 直接读取。
  • 契约一致性:同步更新 test_pr_wait_consumer_adoption.py 以 compose_turn_decision 与 assert_host_task_context(model_input, full) 校验真实的 loopx_turn_model_context_v0 与 task_context 结构。

具体改动 / Changes

依据规范 docs/architecture/rfcs/controller-executor-unified-contract-v0.md(修订 ef099ae3ac3c08054b9d928fff48aefe2615b950)核对两条准则:

  • SOURCE-SESSION-DENIAL:禁止未在 allowlist 中的直接 load_project_registry 调用,外部 source_registry 触发 ProjectRegistryProtocolError(由 test_source_session_registry_denial.py 全量验证 PASS)。
  • TURN-CONSUMER-CONTRACT:真实子进程消费者仅消费 task_context 并排除旧 work_contract(由 test_pr_wait_consumer_adoption.py 实跑验证 PASS)。

关键代码讲解

  1. loopx/presentation/goal_storage_api.py:150(GoalStorageRequestMixin._storage_cold_snapshot):将 load_project_registry(source_registry) 替换为 load_registry(source_registry),纳入标准化注册表兼容性与 source-session 拒绝校验。
  2. tests/architecture/test_source_session_registry_denial.py:205(test_cold_snapshot_rejects_routed_source_session_registry):构建含 SOURCE_SESSION_PROFILE_ID 的外部注册表,直接断言冷快照路径抛出 ProjectRegistryProtocolError。
  3. tests/control_plane/test_pr_wait_consumer_adoption.py:84(test_selected_merge_proof_survives_capture_and_actual_host_adoption):将截获点由已废止的 build_turn_envelope 更新为 compose_turn_decision,并通过 assert_host_task_context 核对真实 task_context。

对主干的风险 / Risks

变更极小(3 files, +57/-8),仅涉及受 allowlist 保护的单一冷快照读入分支与两个测试断言更新。运行 semantic-vocabulary-drift-smoke.py(含 validate_project_registry_io_manifest)实测通过,说明移除 goal_storage_api.py 的直接加载未破坏注册表 IO 清单一致性。另注 goal_storage_api.py 第 328/345 行存在 4 处与本 PR 无关的基线 mypy 历史报错(本 PR 仅触及 150-154 行)。

验证项 级别 结果 实跑输出(exact head 64f6db6f1abae4878175cdb19b11aecdf32635d7)
pytest -q tests/architecture/test_source_session_registry_denial.py tests/control_plane/test_pr_wait_consumer_adoption.py tests/architecture/test_top_level_module_budget.py required PASS 22 passed in 13.10s
ruff check loopx/presentation/goal_storage_api.py tests/... required PASS All checks passed!
loopx canary premerge --from-git-diff --git-diff-base origin/main --tier quick required PASS selected_checks: 2, failures: 0, ok: true (maintainability-ratchet + semantic-vocabulary-drift 含 IO manifest)

我的整体评价 / Verdict

对精确 head 64f6db6f1abae4878175cdb19b11aecdf32635d7 的评价:用户体验影响 not_applicable(仅修改内部 HTTP 冷快照加载函数与后端单元测试,无 UI 页面、样式或命令行提示改动(inspected: loopx/presentation/goal_storage_api.py)。,unverified_scope: none),长程稳定度 improved。通过单一 4 行收口同时恢复 origin/main 的 test_source_session_registry_denial 红线、新增精确负面拒绝用例并验证通过完整 IO 清单烟测(compatibility_assessment=not_applicable,semantic_alignment=not_applicable),同意合入。

English verdict: APPROVE

@mergify

mergify Bot commented Nov 20, 2026

Copy link
Copy Markdown

This pull request has merge conflicts with main and cannot be merged
until they are resolved. Please rebase or merge the base branch, @loopx-agent.

Choose the remote for the base repository, not an out-of-date fork.
For a fork clone, first inspect git remote -v; upstream must point
to https://github.com/loopx-project/loopx.git. If it is absent, add it
with git remote add upstream https://github.com/loopx-project/loopx.git.
Then run:

git fetch upstream
git rebase upstream/main
# Resolve each conflict, git add the resolved files, then git rebase --continue.
git push --force-with-lease origin HEAD

For a same-repository clone whose origin points to
https://github.com/loopx-project/loopx.git, use origin instead of
upstream for fetch/rebase. If you prefer merging the base, use
git merge <base-remote>/main and push normally.

Keep the DCO Signed-off-by trailer on every commit when you rebase.
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 20, 2026

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

动机 / Motivation

用冷存储恢复 Goal 的维护者,以及在 PR 依赖解除后从 DSH 宿主继续原任务的 Agent。 提案基线的冷存储路径与同族导入未共用兼容性入口,依赖恢复测试仍读旧的 Turn 请求字段。 同一仓库现有存储及宿主套件在准确头覆盖正常的注册来源、长期回读、实际 DSH 消费和拒绝分支。主干等价实现通过独立目标复验。 冷存储与来源兼容性共用同一读取 owner。实际 DSH runner 明确读取 loopx_turn_model_context_v0.task_context 并核对绑定后的完整投影。 范围是已有冷存储入口与现有 DSH 依赖恢复测试。产品调用、持久语义和外部发布权限沿用既有机制。

改动思路 / Approach

继续用项目 registry codec 作为兼容性 owner,并用共享宿主断言验证实际 DSH 读到的投影。 准确头包含一个内部加载路径修复及两份回归用例。当前主干已有基础修复,仍有严格宿主投影与冷存储回归断言的增量。 源码读路径和测试消费者分别收口,保留本地及注册来源路由。主干已经换成等价的 registry loader,PR 独立收益集中在回归约束,不需要重新改产品入口来保留测试价值。

具体改动 / Changes

准确头 64f6db6,merge base ef099ae,3 个文件 +57/-8。以修订 ef099ae 的 controller–executor 契约核对 SHARED-REGISTRY-COMPATIBILITY、ORIGINAL-HOST-ADOPTION、RESUME-RECEIPT-PARITY。 控制面契约

关键代码讲解

  • _storage_cold_snapshot 通过已有 registry codec 读取注册来源。沿用原项目选择和快照构建,兼容性结果仍由该 codec 负责。 冷存储入口
  • test_cold_snapshot_rejects_routed_source_session_registry 把该入口的防护纳入原架构 suite。原套件继续覆盖正常的来源和读回。 范围回归
  • test_selected_merge_proof_survives_capture_and_actual_host_adoption 从 compose_turn_decision 捕获实际决定,在实际运行的 DSH 测试消费者内检查当前输送格式,回到测试进程再核对原 PR 证明和完整 task context。 消费者回归

对主干的风险 / Risks

正常注册来源的冷存储与更新路径通过原有 HTTP fixture。真实 DSH 测试执行依赖恢复后读取当前宿主契约,保留原 PR 事件引用与时间且核对实际 task_context。 准确头既有来源范围和回读拒绝用例均通过。DSH 测试保留原 action signature 异常断言,与新宿主投影检查分别生效。 准确头 72 项测试通过,Ruff 通过,quick premerge 的六项直接检查和两项 canary 通过。 当前主干 23dacd5 的三组目标测试共 17 项通过。把准确头的严格 DSH 回归单独放进临时副本,跑当前主干四项全部通过。模拟合并仍在 storage API 和 DSH 测试两个路径冲突。 现行主干测试接受过渡期字段,当前 PR 直接断言当前 schema 和实际模型上下文,所以测试增量仍有独立价值。限定为观察与结构验证,两处原产品调用继续使用共用 owner。

我的整体评价 / Verdict

批准准确头的变更与测试。继续用项目 registry codec 作为兼容性 owner,并用共享宿主断言验证实际 DSH 读到的投影。 准确头包含一个内部加载路径修复及两份回归用例。当前主干已有基础修复,仍有严格宿主投影与冷存储回归断言的增量。 合入需基于当前 main 处理两个冲突,优先保留有价值的回归覆盖。验证范围为本地 HTTP 和真实路径加载的 DSH 测试消费者,未验证已安装宿主或远端 CI。 UI 布局保持原有实现;本轮验证的是存储与上下文消费路径。

English verdict: APPROVE at 64f6db6. The defensive loader and actual DSH adoption tests pass. The current main already has the base fixes; merging this unchanged proposal is held by two conflicts.

@loopx-agent
loopx-agent merged commit 29bc0de into main Nov 21, 2026
3 of 6 checks passed
@loopx-agent
loopx-agent deleted the codex/fix-cold-snapshot-source-denial-and-turn-adoption-20261117 branch November 21, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-rebase Mergify: the pull request has merge conflicts with its base branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant